package com.winsdom.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.winsdom.anno.Authentication;
import com.winsdom.annotation.OperationLog;
import com.winsdom.dto.SysOperationLogSearchDTO;
import com.winsdom.entity.SysOperationLog;
import com.winsdom.enums.AuthenticationType;
import com.winsdom.result.PageResult;
import com.winsdom.service.ISysOperationLogService;
import com.winsdom.service.ScheduledNotificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/operationlog")
@RestController
@Api(tags = "操作日志")
@Slf4j
@Authentication(AuthenticationType.LOG_QUERY)
public class OperationlogController {
    @Autowired
    private ISysOperationLogService sysOperationLogService;
    @Autowired
    private ScheduledNotificationService scheduledNotificationService;


    /**
     * 查询操作日志列表
     *
     * @param sysOperationLogSearchDTO 查询条件
     * @return 操作日志列表
     */
    @PostMapping("/search")
    @ApiOperation("条件查询操作日志列表")
    @OperationLog(description = "条件查询操作日志列表")
    public PageResult search(@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
                             @Parameter(description = "每页条数") @RequestParam(defaultValue = "10") Integer pageSize,
                             @RequestBody SysOperationLogSearchDTO sysOperationLogSearchDTO){
        log.info("条件查询操作日志列表,页码：{}，每页条数：{}，查询条件：{}",pageNum,pageSize,sysOperationLogSearchDTO);
        Page<SysOperationLog> page = sysOperationLogService.search(pageNum,pageSize,sysOperationLogSearchDTO);
        return new PageResult(page.getTotal(),page.getRecords(),pageNum,pageSize);
    }





}
